package client;

import java.util.List;

import gui.AppClient;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import api.Person;

import server.IAmServer;

public class RmiClient
{
   private IAmServer server;
   private static RmiClient client;

   public void setServer(IAmServer server)
   {
      this.server = server;
   }

   public static void main(String[] args)
   {
      System.setSecurityManager(new java.rmi.RMISecurityManager());
      ApplicationContext context = new ClassPathXmlApplicationContext("client_config.xml");
      client = (RmiClient) context.getBean("Client");
      new AppClient().show();
   }

    public static List<Person> loadAll()
    {
       return RmiClient.client.server.loadAll();
    }
   
   public static Long addPerson(Person person)
   {
      return RmiClient.client.server.add(person);
   }
   
   public static void deletePerson(Person person)
   {
      RmiClient.client.server.delete(person);
   }
   
   public static void updatePerson(Person person)
   {
      RmiClient.client.server.edit(person);
   }
}
